package com.etone.smartAudit.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.etone.smartAudit.domain.AdminMenu;
import com.etone.smartAudit.domain.AdminPermission;
import com.etone.smartAudit.vo.permission.PermissionSimpleVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * @author: 蒋学伟
 * @date: 2018-11-01 21:32:49
 * @description:
 */
@Mapper
public interface AdminPermissionMapper extends BaseMapper<AdminPermission> {

    /**
     * 根据角色id查找权限
     *
     * @param roleIds
     * @return
     */
    List<AdminPermission> findByRoleIds(@Param("roleIds") List<Integer> roleIds);

    /**
     * 根据url和method查看权限
     *
     * @param url
     * @param method
     * @return
     */
    List<AdminPermission> findByUrlAndMethod(@Param("url") String url, @Param("method") String method);

    /**
     * 查看用户是否拥有权限
     *
     * @param adminId
     * @param names
     * @return
     */
    boolean hasPermission(@Param("adminId") Integer adminId, @Param("names") List<String> names);

    /**
     * 查找所有有效权限
     *
     * @return
     */
    List<AdminPermission> findAll();

    /**
     * 查询菜单权限
     *
     * @param menuId
     * @return
     */
    List<PermissionSimpleVO> findByMenuId(@Param("menuId") Integer menuId);

    /**
     * 查看name权限是否存在
     *
     * @param name
     * @return
     */
    boolean hasPermissionByName(String name);

    /**
     * 删除菜单权限
     *
     * @param menuId
     * @return
     */
    int deleteMenuPermissionByMenuId(@Param("menuId") Integer menuId);

    /**
     * 新增菜单权限
     *
     * @param menuId
     * @param permissionIds
     * @return
     */
    int insertMenuPermissionByMenuId(@Param("menuId") Integer menuId, @Param("permissionIds") List<Integer> permissionIds);

    List<AdminMenu> findmenuByRoleAndPersionId(@Param("roleId") Integer roleId, @Param("permissionIds") List<Integer> permissionIds);

    Integer getPermissionByMenuIdAndPermissionId(@Param("menuId") Integer menuId, @Param("permissionId") Integer permissionId);

    List<AdminPermission> findByNameAndMethod(@Param("mehodName") String url, @Param("method") String method);
}